home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
presto
/
presto10.lha
/
src
/
mips_swtch.s
< prev
next >
Wrap
Text File
|
1991-12-11
|
3KB
|
133 lines
#include <asm.h>
#include <mips/regdef.h>
#define regspace 9 * 4 + 4 + 6 * 8
#define floats 0
#define registers floats + 6 * 8
#define returnaddr regspace - 4
#define topstack 0
.text
.align 2
.file 2 "mips_swtch.s"
# _init_stack(Thread* this (a0), int* topOfStack(a1))
# Initialize the top frame on the stack
.globl init_stack
.ent init_stack
init_stack:
subu sp, regspace
.frame sp, regspace, ra
/* Save registers. */
sw s0, registers + 0(sp)
sw s1, registers + 4(sp)
sw s2, registers + 8(sp)
sw s3, registers + 12(sp)
sw s4, registers + 16(sp)
sw s5, registers + 20(sp)
sw s6, registers + 24(sp)
sw s7, registers + 28(sp)
sw s8, registers + 32(sp)
/* Save return address */
sw ra, returnaddr(sp)
.mask 0xc0ff0000, -4
/* Save floating point registers */
s.d $f20, floats + 0(sp)
s.d $f22, floats + 8(sp)
s.d $f24, floats + 16(sp)
s.d $f26, floats + 24(sp)
s.d $f28, floats + 32(sp)
s.d $f30, floats + 40(sp)
.fmask 0x55400000, regspace
sw sp, 24(a0) # save current sp in "this"
move sp, a1 # initialize new sp
j ra
.end init_stack
# swtch__6ThreadFv() a.k.a Thread::swtch()
.globl swtch__6ThreadFv
.ent swtch__6ThreadFv 2
swtch__6ThreadFv:
subu sp, regspace
.frame sp, regspace, ra
/* Save registers. */
sw s0, registers + 0(sp)
sw s1, registers + 4(sp)
sw s2, registers + 8(sp)
sw s3, registers + 12(sp)
sw s4, registers + 16(sp)
sw s5, registers + 20(sp)
sw s6, registers + 24(sp)
sw s7, registers + 28(sp)
sw s8, registers + 32(sp)
/* Save return address */
sw ra, returnaddr(sp)
.mask 0xc0ff0000, -4
/* save floating point registers */
s.d $f20, floats + 0(sp)
s.d $f22, floats + 8(sp)
s.d $f24, floats + 16(sp)
s.d $f26, floats + 24(sp)
s.d $f28, floats + 32(sp)
s.d $f30, floats + 40(sp)
.fmask 0x55400000, regspace
# save current sp in reg 5
move t0, sp
# load current sp/fp from hidden first argument this
lw sp, 24(a0)
# store prev sp in "this"
sw t0, 24(a0)
# restore
lw s0, registers + 0(sp)
lw s1, registers + 4(sp)
lw s2, registers + 8(sp)
lw s3, registers + 12(sp)
lw s4, registers + 16(sp)
lw s5, registers + 20(sp)
lw s6, registers + 24(sp)
lw s7, registers + 28(sp)
lw s8, registers + 32(sp)
lw ra, returnaddr(sp)
/* restore floats */
l.d $f20, floats + 0(sp)
l.d $f22, floats + 8(sp)
l.d $f24, floats + 16(sp)
l.d $f26, floats + 24(sp)
l.d $f28, floats + 32(sp)
l.d $f30, floats + 40(sp)
addu sp, regspace
j ra
.end _swtch__6ThreadFv
#ifdef notdef
# MipsSaveSP(int *savsp)
.globl MipsSaveSP
.ent MipsSaveSP 2
MipsSaveSP:
.option O1
.frame sp, 0, $31
sw sp, ($4)
j $31
.end MipsSaveSP
# MipsRestoreSP(int *savsp)
.globl MipsRestoreSP
.ent MipsRestoreSP 2
MipsRestoreSP:
.option O1
.frame sp, 0, $31
move sp,$4 # sp = $4
j $31
.end MipsRestoreSP
#endif